Rem  Copyright (c) 1999, 2000 by Marcelo F. Ochoa.  All Rights Reserved.
Rem
Rem   NAME
Rem     xtf.bdy - DB Prism Xml Toolkit Functions (xtf)
Rem   PURPOSE
Rem     Install the PL/SQL needed to run the XML Application.
Rem   NOTES
Rem
Rem   HISTORY
Rem     mochoa@ieee.org   04/02/02 -
Rem       add comment function
Rem     mochoa@ieee.org   07/02/02 -
Rem       Funtionality for Cocoon 2
Rem       add constants encoding,defaultEncoding and contentType
Rem     mochoa@ieee.org   11/17/00 -
Rem		    add Content-type: text/xml in prolog function
Rem		    replace xtf.tag(cname,cvalue,bclose)
Rem		    by xtf.tag(cname,cvalue,cattributes)
Rem     mochoa@ieee.org   1/7/00 -  Creation version 1.0.0
Rem

CREATE OR REPLACE PACKAGE body xtf IS
-- version 2.0.0
--   added function
--     comment
--   added constants
--     encoding
--     defaultEncoding
--   used by xtp toolkit
-- obsoletes funtions:
--   xtf.prolog(cversion,cstylesheet,cmedia,cattrbutes) replaced by xtp.prolog(cversion)
--   xtf.stylesheet(...)
--   xtf.process(...)
--   xtf.not_found
----------------------------------------------
-- version 1.0.1
--   replace xtf.tag(cname,cvalue,bclose)
--   by xtf.tag(cname,cvalue,cattributes)
--
----------------------------------------------
-- version 1.0.0
-- initial

/* This function is private to the XTF package */
function IFNOTNULL(str1 in varchar2, str2 in varchar2) return varchar2 is
begin
	if (str1 is NULL)
		then return (NULL);
		else return (str2);
	end if;
end;

/******************************************************************/
/* Function macro for if then else -- ite                         */
/******************************************************************/
function ite( tf in boolean, yes in varchar2, no in varchar2 )
	return varchar2
is
begin
	if ( tf ) then
		return yes;
	else
		return no;
	end if;
end ite;

function prolog(cversion in VARCHAR2 default '1.0') return VARCHAR2 is
begin
   return
'<?xml version="'||cversion||'" encoding="'||encoding||'"?>';
end prolog;

function comment(ccomment in VARCHAR2) return VARCHAR2 is
begin
   return
'<-- '||ccomment||' -->';
end comment;

function epilog return VARCHAR2 is
begin
   return
'<!-- toolkit version 2.0.0 -->';
end epilog;

function tag(cname in VARCHAR2,
		cvalue in VARCHAR2,
		cattributes in VARCHAR2 default NULL) return VARCHAR2 is
begin
   return
'<'||cname||IFNOTNULL(cattributes,' '||cattributes)||'>'||cvalue||'</'||cname||'>';
end tag;

function tagOpen(cname in VARCHAR2, cattributes in VARCHAR2 default NULL) return VARCHAR2 is
begin
   return
'<'||cname||IFNOTNULL(cattributes,' '||cattributes)||'>';
end tagOpen;

function tagClose(cname in VARCHAR2) return VARCHAR2 is
begin
   return
'</'||cname||'>';
end tagClose;

END xtf;
/
